package ict.kth.se.model.repository;

import ict.kth.se.exceptions.EntityAlreadyExistsInDBException;
import ict.kth.se.exceptions.EntityDoesntExistInDBException;
import ict.kth.se.model.Person;

import java.sql.SQLException;
import java.util.List;

public interface PersonRepository {
	
	/**
	 * Method for getting all persons
	 * @return All persons
	 */
	public List<Person> getAllPersons() throws SQLException;
	
	/**
	 * This method retrieves person by it's id
	 * @param id Id of person which is to be found
	 * @return Found person or null if none found
	 * @throws SQLException 
	 */
	public Person getPersonById(Long id) throws SQLException;
	
	/**
	 * This method retrieves person by it's ssn
	 * @param ssn Ssn of person which is to be found
	 * @return Found person or null if none found
	 * @throws SQLException 
	 */
	public Person getPersonBySsn(String ssn) throws SQLException;
	
	/**
	 * This method removes one user from database (by it's ID)
	 * @param person The person to be removed
	 * @throws EntityDoesntExistInDBException If person doesn't exist in database
	 * @throws SQLException
	 */
	public void removePerson(Person person) throws EntityDoesntExistInDBException, SQLException;
	
	/**
	 * This method adds an person in DB
	 * @param person Person to be added
	 * @return Newly created person
	 * @throws EntityAlreadyExistsInDBException If such person already exists in DB (by username)
	 * @throws SQLException
	 */
	public Person createPerson(Person person) throws EntityAlreadyExistsInDBException, SQLException;
	
	/**
	 * This method updates an person in DB
	 * @param person Person to be updated
	 * @throws EntityDoesntExistInDBException If such person doesn't exist in DB (by id)
	 * @throws SQLException
	 */
	public void updatePerson(Person person) throws EntityDoesntExistInDBException, SQLException;
	
}
